package com.mac.macjetpackdemo.view

import android.content.Context
import android.util.AttributeSet
import android.view.InputDevice
import android.view.MotionEvent
import android.widget.FrameLayout
import com.mac.macjetpackdemo.log

class AViewGroup(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) {
    private val TAG = "AViewGroup.."
    override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
        super.onLayout(changed, left, top, right, bottom)
    }

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        log(TAG + "dispatchTouchEvent ${ev.hashCode()}")
        return super.dispatchTouchEvent(ev)
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        log(TAG + "onInterceptTouchEvent ${ev?.isFromSource(InputDevice.SOURCE_MOUSE)} ")
        return super.onInterceptTouchEvent(ev)
    }

    override fun setOnTouchListener(l: OnTouchListener?) {
        super.setOnTouchListener(l)
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        log(TAG + "onTouchEvent ${event.hashCode()}")
        return true
    }
}